package io.github.cubelitblade.librarymanagementbackend.exception;

import io.github.cubelitblade.librarymanagementbackend.utils.BusinessStatus;
import lombok.Getter;

@Getter
public class BusinessException extends RuntimeException {
    private final BusinessStatus status;

    public BusinessException(BusinessStatus status) {
        this.status = status;
    }

    public BusinessException(BusinessStatus status, String message) {
        super(message);
        this.status = status;
    }

    public static BusinessException businessFailure() {
        return new BusinessException(BusinessStatus.BUSINESS_FAILURE, "Business failure");
    }

    public static BusinessException notImplemented() {
        return new BusinessException(BusinessStatus.NOT_IMPLEMENTED, "Not implemented");
    }

    public static BusinessException databaseError() {
        return new BusinessException(BusinessStatus.DATABASE_ERROR, "Database error");
    }

    public static BusinessException userAlreadyExist() {
        return new BusinessException(BusinessStatus.USER_ALREADY_EXIST, "User already exist");
    }

    public static BusinessException userNotFound() {
        return new BusinessException(BusinessStatus.USER_NOT_FOUND, "User not found");
    }

    public static BusinessException passwordIncorrect() {
        return new BusinessException(BusinessStatus.PASSWORD_INCORRECT, "Password incorrect");
    }

    public static BusinessException nullKeyField() {
        return new BusinessException(BusinessStatus.NULL_KEY_FIELD, "Null key field");
    }

    public static BusinessException unauthorized() {
        return new BusinessException(BusinessStatus.UNAUTHORIZED, "Unauthorized");
    }

    public static BusinessException sessionExpired() {
        return new BusinessException(BusinessStatus.SESSION_EXPIRED, "Session Expired");
    }

    public static BusinessException bookNotFound() {
        return new BusinessException(BusinessStatus.BOOK_NOT_FOUND, "Book not found");
    }

    public static BusinessException bookOutOfStock() {
        return new BusinessException(BusinessStatus.BOOK_OUT_OF_STOCK, "Book out of stock");
    }

    public static BusinessException bookStockOverflow() {
        return new BusinessException(BusinessStatus.BOOK_STOCK_OVERFLOW, "Book stock overflow");
    }

    public static BusinessException borrowRecordNotFound() {
        return new BusinessException(BusinessStatus.BORROW_RECORD_NOT_FOUND, "Borrow record not found");
    }

    public static BusinessException borrowRecordStatusConflict() {
        return new BusinessException(BusinessStatus.BORROW_RECORD_STATUS_CONFLICT, "Borrow record status conflict");
    }

    public static BusinessException favoriteRecordNotFound() {
        return new BusinessException(BusinessStatus.FAVORITE_RECORD_NOT_FOUND, "Favorite record not found");
    }

    public static BusinessException favoriteRecordStatusConflict() {
        return new BusinessException(BusinessStatus.FAVORITE_RECORD_STATUS_CONFLICT, "Favorite record status conflict");
    }
}
